<template>
	<view class="indexBox">
		<view class="btn" @tap.stop="home">跳过{{time}}</view>
		<image :src="img+image" mode=""></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				time: 3,
				image: '',
				img: this.$base.smallimgUrl
			};
		},
		onLoad() {
			this.getPageData()
		},
		methods: {
			getPageData() {
				let that = this
				that.$api.launch_page().then(res => {
					console.log(res)
					that.image = res.data.data.advimage[0]
					that.countDown()
				})
			},
			// 倒计时
			countDown(){
				let that = this
				let _time = setInterval(() => {
					that.time--
					if(that.time == 0){
						clearInterval(_time)
						uni.switchTab({
							url: '/pages/tabBar/home/home'
						})
						
					}
				},1000)
			},
			home(){
				uni.switchTab({
					url: '/pages/tabBar/home/home'
				})
			}
		}
	}
</script>

<style lang="less">
	.indexBox {
		width: 100vw;
		height: 100vh;

		image {
			width: 100%;
			height: 100%;
		}

		.btn {
			width: 200rpx;
			height: 80rpx;
			line-height: 80rpx;
			color: #fff;
			background-color: rgba(255, 255, 255, 0.1);
			text-align: center;
			border-radius: 80rpx;
			position: fixed;
			top: 40rpx;
			right: 40rpx;
		}
	}
</style>
